<?php
include_once '../action/pejabatController.php';
include 'z_header.php';
if(!isset($_SESSION['nip'])){
    header('location:login.php');
}?>
<div class="container">  
    <div class="row">
<?php if(isset($_GET['view'])){
?> 
<!--AWAL TABEL LIHAT PEJABAT -->
<div class="span12 accordion-group" id="tabel_pejabat">
<table class="table table-striped">  
    <fieldset>  
        <legend>&nbsp;REFERENSI PEJABAT</legend> 
        <thead>  
          <tr>  
            <th>Nomor</th>  
            <th>Jabatan</th>  
            <th>NIP Pejabat</th>
            <th>Nama Pejabat</th>  
            <?php if($_SESSION['admin']=="Y"){ ?>
            <th>Aksi</th> 
            <?php } ?>
          </tr>  
        </thead>  
        <tbody> 
            <?php 
            if($data!=NULL){
                foreach ($data as $pej){
            ?>
          <tr>  
            <td><?php echo $pej->id_seksi-1; ?></td>  
            <td><?php echo $pej->nama_jabatan; ?></td> 
            <td><?php echo $pej->nip; ?></td> 
            <td><?php echo $pej->nm_pjbt; ?></td>
            <?php if($_SESSION['admin']=="Y"){ ?>
            <td>
            <a href="?ubah&id=<?php echo $pej->id_seksi; ?>"><button class="btn btn-warning"><i class="icon-edit" align="center" ></i> Ubah</button></a>
            </td>
            <?php } ?>
          </tr>  
                <?php } 
            }?>
        </tbody>  
        </fieldset>
      </table>
</div>
<?php } ?>
<!--AKHIR TABEL LIHAT PEJABAT -->


<!--AWAL FORM UBAH PEJABAT -->
<?php
 if(isset($_GET['ubah']) AND $_SESSION['admin']=="Y"){
     if(isset($error))
        {
                echo '<div class="alert alert-error" id="alert">'.$error.'
                      <button type="button" class="close" data-dismiss="alert" id="close">×</button></div>';
        }
     foreach ($data_ubah as $pej) {
?>
<div class="span7 offset3 accordion-group" id="form_ubahpjbt">
    <div class="span6">
    <form class="form-horizontal" method="post" action="">
        <legend>&nbsp;UBAH REFERENSI PEJABAT</legend> 
            <div class="control-group">  
                    <div class="controls">  
                        <input type="hidden" class="input-xlarge" name="id_seksi" value="<?php echo $pej->id_seksi;?>">
                    </div>  
            </div> 
            
            <div class="control-group">  
                  <label class="control-label" for="nm_seksi">Nama Bagian/Seksi</label>  
                      <div class="controls">   
                          <input class="input-xlarge uneditable-input" name="nm_seksi" disabled value="<?php echo $pej->nama_jabatan; ?>">    
                      </div>  
            </div> 
            
           <div class="control-group">
                <label class="control-label" for="inputEmail">Nama Pejabat</label>
                        <div class="controls">
                            <select name="pejabat" class="input-xlarge">
                                <option value="<?php echo $pej->pejabat; ?>"><?php echo $pej->nm_pjbt; ?></option>
                                    <?php
                                        foreach($data_nama as $nama){ ?>
                                            <option value="<?php echo $nama->pejabat;?>"><?php echo $nama->nm_pjbt; ?></option>
                                    <?php    } ?>
                            </select>
                        </div>
            </div>

            <div class="form-actions"> 
                <button type="button" class="btn btn-secondary button-info" onclick="window.self.history.back()">Batal</button>
                <button type="submit" class="btn btn-primary" name="simpan_pejabat" id="simpan_pjbt">Simpan</button>  
            </div> 
    </form> 
    </div>
</div>
     <?php }
 } ?>
<!--AKHIR FORM UBAH PEJABAT -->                                           
<?php include_once 'z_footer.php'; ?>